package com.dr.web.controllers;

import com.dr.pojo.DirInfo;
import com.dr.pojo.PhtotInfo;
import com.dr.service.PhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by tugou on 2017/5/27.
 */
@Controller
@RequestMapping("photo")
public class PhotoController {

    @Autowired
    PhotoService photoService;

    @RequestMapping(value="showList",method= RequestMethod.GET)
    public String showPageList(Model model, HttpServletRequest request){
        List<DirInfo> list = photoService.getAllList(request);
        model.addAttribute("dirList",list);
        return "DriverRecode/index";
    }


    @RequestMapping(value="showPhoto/{dirNmae}",method= RequestMethod.GET)
    public String showPage(Model model, HttpServletRequest request,@PathVariable String dirNmae){
        List<PhtotInfo> list = photoService.getPhotoListByDirName(dirNmae,request);
        model.addAttribute("photoList",list);
        return "DriverRecode/pictureList";
    }

}
